package com.gxa.retail_admin.controller;


import com.gxa.common.vo.ResultVo;
import com.gxa.modules.pojo.*;
import com.gxa.modules.service.InventoryService;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;


@Controller
@RequestMapping("/inventory")
@Api(value = "库存中心",tags = "库存中心接口API")
public class InventoryController {
    private ResultVo resultVo = new ResultVo();
    @Autowired(required = false)
    private InventoryService inventoryService;
    public  String addId(){
        return null;
    }
    @RequestMapping(value = "/queryInventory",method = RequestMethod.GET)
    @ApiOperation(value = "查询库存查询接口",notes = "库存查询基本信息",httpMethod = "GET", response = ResultVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "sh_id",value = "店铺id",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "String",required = true),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    @RequiresPermissions("库存查询")
    public ResultVo queryInventory(Integer sh_id,Integer currentPage,Integer pageSize){
        ResultVo resultVo = inventoryService.queryInventory(sh_id,currentPage,pageSize);
        return resultVo;
    }
    @RequestMapping(value = "/queryGoodstores",method = RequestMethod.GET )
    @ApiOperation(value = "查询要货门店接口",notes = "要货门店基本信息",httpMethod = "GET", response = ResultVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "sh_id",value = "店铺id",paramType = "query",dataType = "String",required = true),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    @RequiresPermissions("要货门店")
    public ResultVo queryGoodstores(@RequestParam(value = "currentPage") Integer currentPage, @RequestParam(value = "pageSize") Integer pageSize,Integer sh_id){
        ResultVo resultVo = inventoryService.queryGoodstores(currentPage,pageSize,sh_id);
        return resultVo;
    }

    @RequestMapping(value = "/addGoodsTores",method = RequestMethod.POST )
    @ApiOperation(value = "添加门店要货单",httpMethod = "POST", response = ResultVo.class)
    @ApiImplicitParam(name = "goods_stores",value = "添加信息",paramType = "add",dataType = "Goods_Stores",required = true)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    @RequiresPermissions("要货门店")
    public ResultVo addGoodsTores(Goods_Stores goods_stores){
        return null;
    }
    @RequestMapping(value = "/queryCargoStorage",method = RequestMethod.GET)
    @ApiOperation(value = "查询要货入库接口",notes = "要货入库基本信息",httpMethod = "GET", response = ResultVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "sh_id",value = "店铺id",paramType = "query",dataType = "String",required = true),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    @RequiresPermissions("要货入库")
    public ResultVo queryCargoStorage(@RequestParam(value = "currentPage") Integer currentPage,@RequestParam(value = "pageSize") Integer pageSize,Integer sh_id){
        ResultVo resultVo = inventoryService.queryCargoStorage(currentPage,pageSize,sh_id);
        return resultVo;
    }
    @RequestMapping(value = "/addCargoStorage",method = RequestMethod.POST )
    @ApiOperation(value = "添加要货入库",httpMethod = "POST", response = ResultVo.class)
    @ApiImplicitParam(name = "cargo_storage",value = "添加信息",paramType = "add",dataType = "Cargo_Storage",required = true)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    @RequiresPermissions("要货入库")
    public ResultVo addCargoStorage(Cargo_Storage cargo_storage){
        return null;
    }
    @RequestMapping(value = "/queryStoresAllocate",method = RequestMethod.GET)
    @ApiOperation(value = "查询门店调拨接口",notes = "门店调拨基本信息",httpMethod = "GET", response = ResultVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "sh_id",value = "店铺id",paramType = "query",dataType = "String",required = true),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    @RequiresPermissions("门店调拨")
    public ResultVo queryStoresAllocate(@RequestParam(value = "currentPage") Integer currentPage,@RequestParam(value = "pageSize") Integer pageSize,Integer sh_id){
        ResultVo resultVo = inventoryService.queryStoresAllocate(currentPage,pageSize,sh_id);
        return resultVo;
    }
    @RequestMapping(value = "/addStoresAllocate",method = RequestMethod.POST )
    @ApiOperation(value = "添加门店调拨单",httpMethod = "POST", response = ResultVo.class)
    @ApiImplicitParam(name = "cargo_storage",value = "添加信息",paramType = "add",dataType = "Stores_Allocate",required = true)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    @RequiresPermissions("门店调拨")
    public ResultVo addStoresAllocate(Stores_Allocate stores_allocate){
        return null;
    }
    @RequestMapping(value = "/queryWareHouseDamage",method = RequestMethod.GET)
    @ApiOperation(value = "查询库存报损接口",notes = "库存报损基本信息",httpMethod = "GET", response = ResultVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "sh_id",value = "店铺id",paramType = "query",dataType = "String",required = true),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    @RequiresPermissions("库存报损")
    public ResultVo queryWareHouseDamage(@RequestParam(value = "currentPage") Integer currentPage,@RequestParam(value = "pageSize") Integer pageSize,Integer sh_id){
        ResultVo resultVo = inventoryService.queryWareHouseDamage(currentPage,pageSize,sh_id);
        return resultVo;
    }
    @RequestMapping(value = "/addWareHouseDamage",method = RequestMethod.POST )
    @ApiOperation(value = "添加库存报损单",httpMethod = "POST", response = ResultVo.class)
    @ApiImplicitParam(name = "cargo_storage",value = "添加信息",paramType = "add",dataType = "WareHouse_Damage",required = true)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    @RequiresPermissions("库存报损")
    public ResultVo addWareHouseDamage(WareHouse_Damage wareHouse_damage){
        return null;
    }
    @RequestMapping(value = "/queryGoodsTable",method = RequestMethod.GET)
    @ApiOperation(value = "查询派货列表接口",notes = "派货列表基本信息",httpMethod = "GET", response = ResultVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "sh_id",value = "店铺id",paramType = "query",dataType = "String",required = true),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    @RequiresPermissions("派货列表")
    public ResultVo queryGoodsTable(@RequestParam(value = "currentPage") Integer currentPage,@RequestParam(value = "pageSize") Integer pageSize,Integer sh_id){
        ResultVo resultVo = inventoryService.queryGoodsTable(currentPage,pageSize,sh_id);
        return resultVo;
    }
    @RequestMapping(value = "/queryShipmentstorage",method = RequestMethod.GET)
    @ApiOperation(value = "查询派货入库接口",notes = "派货入库基本信息",httpMethod = "GET", response = ResultVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "sh_id",value = "店铺id",paramType = "query",dataType = "String",required = true),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    @RequiresPermissions("派货入库")
    public ResultVo queryShipmentstorage(@RequestParam(value = "currentPage") Integer currentPage,@RequestParam(value = "pageSize") Integer pageSize,Integer sh_id){
        ResultVo resultVo = inventoryService.queryShipmentstorage(currentPage,pageSize,sh_id);
        return resultVo;
    }
    @RequestMapping(value = "/ddShipmentstorage",method = RequestMethod.POST )
    @ApiOperation(value = "添加派货单入库",httpMethod = "POST", response = ResultVo.class)
    @ApiImplicitParam(name = "cargo_storage",value = "添加信息",paramType = "add",dataType = "Shipments_Storage",required = true)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    @RequiresPermissions("派货入库")
    public ResultVo addShipmentstorage(Shipments_Storage shipments_storage){
        return null;
    }
    @RequestMapping(value = "/queryReturnGoods",method = RequestMethod.GET)
    @ApiOperation(value = "查询退货出库接口",notes = "退货出库基本信息",httpMethod = "GET", response = ResultVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "sh_id",value = "店铺id",paramType = "query",dataType = "String",required = true),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    @RequiresPermissions("退货出库")
    public ResultVo queryReturnGoods(@RequestParam(value = "currentPage") Integer currentPage,@RequestParam(value = "pageSize") Integer pageSize,Integer sh_id){
        ResultVo resultVo = inventoryService.queryReturnGoods(currentPage,pageSize,sh_id);
        return resultVo;
    }
    @RequestMapping(value = "/queryAll",method = RequestMethod.GET)
    @ApiOperation(value = "搜索接口",notes = "搜索单号基本信息",httpMethod = "GET", response = ResultVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "单号",paramType = "query",dataType = "string",required = true),
            @ApiImplicitParam(name = "sh_id",value = "店铺id",paramType = "query",dataType = "int",required = true),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    @RequiresPermissions("库存中心")
    public ResultVo queryAll(@RequestParam(value = "id") String id){
        ResultVo resultVo = inventoryService.queryAll(id);
        return resultVo;
    }
    @RequestMapping(value = "/findAllById",method = RequestMethod.GET )
    @ApiOperation(value = "查看接口",httpMethod = "GET", response = ResultVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "单号",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "sh_id",value = "店铺id",paramType = "query",dataType = "String",required = true),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    @RequiresPermissions("库存中心")
    public ResultVo findAllById(Integer sh_id,String id){
        ResultVo resultVo = inventoryService.findAllById(sh_id,id);
        return resultVo;
    }
    @RequestMapping(value = "/updateStatus",method = RequestMethod.POST )
    @ApiOperation(value = "提交接口",httpMethod = "POST", response = ResultVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "单号",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "sh_id",value = "店铺id",paramType = "query",dataType = "String",required = true),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    @RequiresPermissions("库存中心")
    public ResultVo updateStatus(Integer sh_id,String id){
        return inventoryService.updateStatus(sh_id,id);
    }
    @RequestMapping(value = "/updateGoods",method = RequestMethod.POST )
    @ApiOperation(value = "修改店铺商品",httpMethod = "POST", response = ResultVo.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public ResultVo updateGoods(Map map){
        return inventoryService.updateGoods(map);
    }


}
